%% This code plots Cash Flow Forecasts
clearvars -except Globaloption option

if exist('Globaloption', 'var') == 0
    Globaloption.savefig = 1;
end

loaddata_4CIjoint_annual;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-year
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

run ../../tools/cashflow_1yr.m

ttime = [1947:2020];

startColor = [0.5, 0.5, 0.5];

f = figure;
plot(ttime(2:T), ts_actual_dt, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(2:T), ts_var1y_dt, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(2:T), ts_ols1y_dt, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse1y_dt(1))], ...
    ['OLS, rmse=', num2str(rmse1y_dt(2))], 'location', 'northwest')
%set(gca, 'Layer', 'top','FontSize',9)
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Tax/GDP')
xlim([1947, 2020])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/UK/post1946/forecast_1yr_dt_post', '-dpdf', '-fillpage');
end

f = figure;
plot(ttime(2:T), ts_actual_dg, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(2:T), ts_var1y_dg, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(2:T), ts_ols1y_dg, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse1y_dg(1))], ...
    ['OLS, rmse=', num2str(rmse1y_dg(2))], 'location', 'northwest')
% set(gca, 'Layer', 'top','FontSize',9)
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Spending/GDP')
xlim([1947, 2020])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/UK/post1946/forecast_1yr_dg_post', '-dpdf', '-fillpage');
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 5-year
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

run ../../tools/cashflow_5yr.m

f = figure;
plot(ttime(6:T), ts_actual_dt, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(6:T), ts_var5y_dt, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(6:T), ts_ols5y_dt, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse5y_dt(1))], ...
    ['OLS, rmse=', num2str(rmse5y_dt(2))], 'location', 'northeast')
% set(gca, 'Layer', 'top','FontSize',9)
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Tax/GDP')
xlim([1947, 2020])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/UK/post1946/forecast_5yr_dt_post', '-dpdf', '-fillpage');
end

f = figure;
plot(ttime(6:T), ts_actual_dg, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(6:T), ts_var5y_dg, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(6:T), ts_ols5y_dg, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse5y_dg(1))], ...
    ['OLS, rmse=', num2str(rmse5y_dg(2))], 'location', 'northwest')
% set(gca, 'Layer', 'top','FontSize',9)
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Spending/GDP')
xlim([1947, 2020])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/UK/post1946/forecast_5yr_dg_post', '-dpdf', '-fillpage');
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 10-year
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

run ../../tools/cashflow_10yr.m

f = figure;
plot(ttime(11:T), ts_actual_dt, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(11:T), ts_var10y_dt, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(11:T), ts_ols10y_dt, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse10y_dt(1))], ...
    ['OLS, rmse=', num2str(rmse10y_dt(2))], 'location', 'southeast')
% set(gca, 'Layer', 'top','FontSize',9)
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Tax/GDP')
xlim([1947, 2020])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/UK/post1946/forecast_10yr_dt_post', '-dpdf', '-fillpage');
end

f = figure;
plot(ttime(11:T), ts_actual_dg, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(11:T), ts_var10y_dg, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(11:T), ts_ols10y_dg, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse10y_dg(1))], ...
    ['OLS, rmse=', num2str(rmse10y_dg(2))], 'location', 'northwest')
% set(gca, 'Layer', 'top','FontSize',9)
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Spending/GDP')
xlim([1947, 2020])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/UK/post1946/forecast_10yr_dg_post', '-dpdf', '-fillpage');
end
